package com.example.demo.entity.security;

import com.example.demo.utils.MD5Utils;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * @description:
 * @author: cj
 * @create: 09-02-08 09:31:05
 */
public class Md5PasswordEncoder implements PasswordEncoder {
    @Override
    public String encode(CharSequence rawPassword) {
        String md5String = MD5Utils.getMD5String( rawPassword.toString() );
        return md5String;
    }

    @Override
    public boolean matches(CharSequence rawPassword, String encodedPassword) {
        String md5String = MD5Utils.getMD5String( rawPassword.toString() );
        boolean equals = encodedPassword.equals( md5String );
        return equals;
    }
}
